package com.ds.lens.data.security;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Description:
 *
 * @author WeiShaoying
 * @date 2019-11-06
 */
@Component
public class AuthenticationFactory {

    @Autowired
    Map<String, Authentication> map = new ConcurrentHashMap<>();

    public Authentication getAuthentication(String key) throws Exception {
        Authentication authentication = map.get(key);
        if (null == authentication) {
            throw new RuntimeException("no authentication defined");
        }
        return authentication;
    }

}
